package com.mlamp.me;

import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.catalog.hive.HiveCatalog;

/**
 * @author:wy
 * @date:2020/3/31
 * @version:1.0.0
 * @description:
 */
public class IntelligenceAlter {
    public static void main(String[] args) throws Exception {
        EnvironmentSettings settings = EnvironmentSettings.newInstance().useBlinkPlanner().inBatchMode().build();
        TableEnvironment tableEnv = TableEnvironment.create(settings);
        String name            = "hive";
        String defaultDatabase = "tmp";
        String hiveConfDir     = "D:\\assistant\\apache-hive-2.3.9-bin\\conf";
        String version         = "2.3.9";

        HiveCatalog hive = new HiveCatalog(name, defaultDatabase, hiveConfDir, version);
        tableEnv.registerCatalog("hive", hive);
        tableEnv.registerCatalog(name, hive);
        tableEnv.useCatalog(name);

        tableEnv.sqlQuery("select * from tmp.tmp_flink_test_2").select("product_id");
        tableEnv.sqlUpdate("insert into tmp.tmp_flink_test_2 values ('newKey')");
        tableEnv.execute("insert into tmp");
    }
}

